/**
 * 
 */
package com.great.meal.search.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author 小兔子
 * @since 2011-04-14
 */
@Entity
@Table(name = "t_group")
public class Group implements Serializable {

	private static final long serialVersionUID = -5345567704475433946L;

	private Long groupId;
	private String groupName;
	private String belongLocation;
	private String location;
	private Customer manager;
	private Set<Customer> customsers;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getGroupId() {
		return groupId;
	}

	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	@OneToMany
	public Set<Customer> getCustomsers() {
		return customsers;
	}

	public void setCustomsers(Set<Customer> customsers) {
		this.customsers = customsers;
	}

	public Customer getManager() {
		return manager;
	}

	public void setManager(Customer manager) {
		this.manager = manager;
	}

	@Column(length = 64)
	public String getBelongLocation() {
		return belongLocation;
	}

	public void setBelongLocation(String belongLocation) {
		this.belongLocation = belongLocation;
	}

	@Column(length = 64)
	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	@Override
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof Group))
			return false;

		final Group group = (Group) other;

		if (!group.getBelongLocation().equals(getBelongLocation()))  return false;
		if (!group.getGroupId().equals(getGroupId()))  return false;
		if (!group.getGroupName().equals(getGroupName()))
			return false;
		if (!group.getLocation().equals(getLocation()))
			return false;
		if (!group.getManager().equals(getManager()))
			return false;

		return true;
	}
	
	@Override
	public int hashCode(){
		int result = groupId != null ? groupId.hashCode() : 0;
		result = 31 * result + (belongLocation != null ? belongLocation.hashCode() : 0);
		result = 31 * result + (groupName != null ? groupName.hashCode() : 0);
		result = 31 * result + (location != null ? location.hashCode() : 0);
		result = 31 * result + (manager != null ? manager.hashCode() : 0);
		
		return result;
	}

}
